package com.my.hp_hr.contorller;

import com.my.hp_hr.entity.liuhao_entity.Employee;
import com.my.hp_hr.entity.Leave;
import com.my.hp_hr.service.LeaveService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

@WebServlet("/leaveServlet")
public class LeaveNotAgreeServlet extends HttpServlet {
    private LeaveService leaveService = new LeaveService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            HttpSession session = req.getSession();
            Employee employee = (Employee) session.getAttribute("employee_isLogin");
            int department_number = employee.getDepartment_number();
            String status = "未批准";
            List<Leave> list = leaveService.getNotAgreeList(department_number, status);
            req.setAttribute("list",list);
            req.getRequestDispatcher("leave_notlist.jsp").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

    }
}
